(function(){
    "use strict";
    app.controller('alarmCtrl', ['$scope', 'httpLoad', '$rootScope','$modal','$state','$timeout','LANGUAGE',
        function($scope, httpLoad, $rootScope, $modal,$state, $timeout,LANGUAGE) {
            $rootScope.moduleTitle = '告警管理 > 告警管理';//定义当前页
            $rootScope.link = '/statics/css/user.css';//引入页面样式
            $scope.param = {
                rows: 10
            };
            //获取列表
            $scope.getData = function(page){
                $scope.showDetail = false;
                $scope.param.page = page || $scope.param.page;
                var params = {
                        page: $scope.param.page,
                        rows: $scope.param.rows
                    },
                    searchParam = [];
                if($scope.searchByname&&$scope.searchByname!=""){
                    searchParam.push({"param":{"name":$scope.searchByname},"sign":"LK"});
                }
                params.params = JSON.stringify(searchParam);
                httpLoad.loadData({
                    url:'/alarm/list',
                    method: 'POST',
                    data: params,
                    noParam: true,
                    success:function(data){
                        if(data.success&&data.data.rows){
                            $scope.userList = data.data.rows;
                            $scope.totalCount = data.data.total;
                            if(data.data.rows.length==0) {
                                $scope.isImageData = true;
                                return;
                            } else $scope.isImageData = false;
                        }else{
                            $scope.isImageData = true;
                        }
                    }
                });
            };
            $scope.getData(1);
            //跳转详情页
            $scope.detail = function (id) {
                httpLoad.loadData({
                    url:'/alarm/detail',
                    method:'GET',
                    data: {id: id},
                    success:function(data){
                        if(data.success&&data.data){
                            $scope.userDetail = data.data;
                            $scope.showDetail = $scope.isActive = true;
                        }
                    }
                });
            };
            //返回
            $scope.goBack = function(){
                $scope.isActive = false;
                $timeout(function() {
                    $scope.showDetail = false;
                }, 200);
            };
        }
    ]);
})();